package com.wonderland.webtest.controller;

import com.wonderland.webtest.user.service.RedisService;
import com.wonderland.webtest.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * @author gaoxinyu
 */
@Controller
public class HomeController {

    @Autowired
    private RedisService jedisService;

    @Autowired
    private UserService userService;

    @RequestMapping("/")
    public String index(Model model, HttpSession session) {
//        double random = Math.random();
//        if (random < 0.5) {
//            System.out.println("-------------------lamb");
//            DataSourceContextHolder.setDataSourceType("lamb");
//        } else {
//            System.out.println("-------------------smart");
//            DataSourceContextHolder.setDataSourceType("smart");
//        }
//        List<User> userList = userService.getUserList();
//        for (User user : userList) {
//            System.out.println("username:" + user.getUsername());
//        }
        jedisService.test();
        return "/index";
    }

}
